package pers.bc.utils.yonyou;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import nc.itf.bd.psn.psndoc.IPsndocQueryService;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.bd.bankaccount.BankAccSubVO;
import nc.vo.bd.bankaccount.BankAccbasVO;
import nc.vo.bd.cust.CustbankVO;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.bd.defdoc.DefdoclistVO;
import nc.vo.bd.psn.PsnClVO;
import nc.vo.bd.psn.PsndocVO;
import nc.vo.bd.psn.PsnjobVO;
import nc.vo.bd.supplier.SupplierVO;
import nc.vo.gl.rcstvoucher.VoucherVO;
import nc.vo.gl.voucherdetail.VoucherDetailVO;
import nc.vo.hi.psndoc.PsnJobVO;
import nc.vo.org.DeptVO;
import nc.vo.org.GroupVO;
import nc.vo.org.JobTypeVO;
import nc.vo.org.JobVO;
import nc.vo.org.OrgVO;
import nc.vo.org.PostSeriesVO;
import nc.vo.org.PostVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.pub.billtype.BilltypeVO;
import nc.vo.sm.UserVO;
import pers.bc.utils.pub.JsonUtil;
import pers.bc.utils.pub.JudgeAssertUtil;
import pers.bc.utils.pub.PubEnvUtil;
import pers.bc.utils.pub.StringUtil;
import pers.bc.utils.sql.SqlHelper;

/**
 * 
 ** 
 * @qualiFild pers.bc.utils.yonyou.YonDBQuery.java<br>
 * @author：LiBencheng<br>
 * @date Created on 2025-5-23<br>
 * @version 1.0<br>
 */
public class YonNccDB
{
    /**
     * *********************************************************** <br>
     * *说明： <br>
     * @see <br>
     * @param cuserid
     * @return
     * @throws Exception <br>
     * @Map<String,String> <br>
     * @methods pers.bc.utils.yonyou.YonNccDB#getUserByid <br>
     * @author LiBencheng <br>
     * @date Created on 2025年11月18日 <br>
     * @time 下午5:36:05 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public Map<String, String> getUserByid(final String cuserid) throws Exception
    {
        return new LinkedHashMap<String, String>()
        {
            /** @date 2025年11月18日 */
            private static final long serialVersionUID = 7996443889612114409L;
            
            {
                for (Map.Entry<String, Object> entry : getUserObjByid(cuserid).entrySet())
                    PubEnvUtil.setObjValue(this, entry.getKey(), StringUtil.valueOfEmpty(entry.getValue()));
            }
        };
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 获取nc系列 用户信息,包含部门、岗位、职位、级别等<br>
     * @see <br>
     * @param cuserid
     * @return
     * @throws Exception <br>
     * @Map<String,Object> <br>
     * @methods pers.bc.utils.yonyou.YonNccDB#getUserObjByid <br>
     * @author LiBencheng <br>
     * @date Created on 2025年11月18日 <br>
     * @time 下午5:36:01 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public Map<String, Object> getUserObjByid(String cuserid) throws Exception
    {
        Map<String, Object> userMap = new LinkedHashMap<String, Object>();
        UserVO userVO = getUserById(cuserid);
        if (PubEnvUtil.isNotNullObj(userVO))
        {
            userMap.put("userId", cuserid);
            userMap.put("userCodeQ", userVO.getUser_code_q());
            userMap.put("userCode", userVO.getUser_code());
            userMap.put("userName", userVO.getUser_name());
            
            PsndocVO[] psndocVOs = YonYouUtilbc.NccLocator(IPsndocQueryService.class).queryPsndocByPks(new String[]{userVO.getPk_psndoc()});
            for (int i = 0; i < PubEnvUtil.getSize(psndocVOs); i++)
            {
                PsndocVO psndocVO = psndocVOs[i];
                userMap.put("psnId", psndocVO.getPk_psndoc());
                userMap.put("psnCode", psndocVO.getCode());
                userMap.put("psnName", psndocVO.getName());
                // 最新工作记录
                PsnjobVO[] psnjobs = psndocVO.getPsnjobs();
                for (int x = 0; x < PubEnvUtil.getSize(psnjobs); x++)
                {
                    PsnjobVO psnjob = psnjobs[x];
                    if (PubEnvUtil.equals("Y", psnjob.getIsmainjob()) && PubEnvUtil.isNotNullObj(psnjob.getIndutydate()))
                    {
                        OrgVO orgVO = getOrgByPk(psnjob.getPk_org());
                        if (PubEnvUtil.isNotNullObj(orgVO))
                        {
                            userMap.put("orgId", orgVO.getPk_org());
                            userMap.put("orgCode", orgVO.getCode());
                            userMap.put("orgName", orgVO.getName());
                        }
                        
                        DeptVO deptVO = getDeptByPk(psnjob.getPk_dept());
                        if (PubEnvUtil.isNotNullObj(deptVO))
                        {
                            userMap.put("deptId", deptVO.getPk_dept());
                            userMap.put("deptCode", deptVO.getCode());
                            userMap.put("deptName", deptVO.getName());
                        }
                        
                        PostVO postVO = (PostVO) getSuperVOById(psnjob.getPk_post(), PostVO.class);
                        if (PubEnvUtil.isNotNullObj(postVO))
                        {
                            userMap.put("postId", postVO.getPk_post());
                            userMap.put("postCode", postVO.getPostcode());
                            userMap.put("postName", postVO.getPostname());
                            if (PubEnvUtil.isNotNullObj(postVO.getPk_postseries()))
                            {
                                PostSeriesVO postSeriesVO = (PostSeriesVO) getSuperVOById(postVO.getPk_postseries(), PostSeriesVO.class);
                                if (PubEnvUtil.isNotNullObj(postSeriesVO))
                                {
                                    userMap.put("postSeriesId", postSeriesVO.getPk_postseries());
                                    userMap.put("postSeriesCode", postSeriesVO.getPostseriescode());
                                    userMap.put("postSeriesName", postSeriesVO.getPostseriesname());
                                }
                            }
                        }
                        
                        if (PubEnvUtil.isNotNullObj(psnjob.getPk_job()))
                        {
                            JobVO jobVO = (JobVO) getSuperVOById(psnjob.getPk_job(), JobVO.class);
                            if (PubEnvUtil.isNotNullObj(jobVO))
                            {
                                userMap.put("jobId", jobVO.getPk_job());
                                userMap.put("jobCode", jobVO.getJobcode());
                                userMap.put("jobName", jobVO.getJobname());
                                if (PubEnvUtil.isNotNullObj(jobVO.getPk_jobtype()))
                                {
                                    JobTypeVO jobTypeVO = (JobTypeVO) getSuperVOById(jobVO.getPk_jobtype(), JobTypeVO.class);
                                    if (PubEnvUtil.isNotNullObj(jobTypeVO))
                                    {
                                        userMap.put("jobTypeId", jobTypeVO.getPk_jobtype());
                                        userMap.put("jobTypeCode", jobTypeVO.getJobtypecode());
                                        userMap.put("jobTypeName", jobTypeVO.getJobtypename());
                                    }
                                }
                            }
                        }
                        
                        if (PubEnvUtil.isNotNullObj(psnjob.getPk_psncl()))
                        {
                            PsnClVO psnClVO = (PsnClVO) getSuperVOById(psnjob.getPk_psncl(), PsnClVO.class);
                            if (PubEnvUtil.isNotNullObj(psnClVO))
                            {
                                userMap.put("psnClId", psnClVO.getPk_psncl());
                                userMap.put("psnClCode", psnClVO.getCode());
                                userMap.put("psnClName", psnClVO.getName());
                            }
                        }
                    }
                }
                
                userMap.putAll(JsonUtil.toMap(JsonUtil.transObj2Josn(psndocVO)));
            }
        }
        
        return userMap;
    }
    
    /**
     * *********************************************************** <br>
     * *说明： <br>
     * @see <br>
     * @param sql
     * @return
     * @throws BusinessException <br>
     * @List<Map> <br>
     * @methods pers.bc.utils.yonyou.YonNccDB#getData <br>
     * @author LiBencheng <br>
     * @date Created on 2025年11月7日 <br>
     * @time 下午9:58:43 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public List<Map> getData(String sql) throws BusinessException
    {
        return (List<Map>) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, new MapListProcessor());
    }
    
    /**
     * *********************************************************** <br>
     * *说明： <br>
     * @see <br>
     * @param sql
     * @param vo
     * @return
     * @throws BusinessException <br>
     * @List<SuperVO> <br>
     * @methods pers.bc.utils.yonyou.YonNccDB#getDataSuperVO <br>
     * @author LiBencheng <br>
     * @date Created on 2025年11月7日 <br>
     * @time 下午9:58:38 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public List<SuperVO> getDataSuperVO(String sql, SuperVO vo) throws BusinessException
    {
        return (List<SuperVO>) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, new BeanListProcessor(vo.getClass()));
    }
    
    /**
     * *********************************************************** <br>
     * *说明：分录 (gl_detail) <br>
     * checkstyle 结算方式 <br>
     * @see <br>
     * @param $$$ppk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @List<CustbankVO> <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getCustbankList <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:28:42 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    @SuppressWarnings("unchecked")
    public List<VoucherDetailVO> getDetailList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        
        List<VoucherDetailVO> cList = (List<VoucherDetailVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(VoucherDetailVO.class,
            "(  pk_voucher /*凭证主键  */   ='" + $$$ppk_ags0 + "')");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(cList) < 1, folder, "+++++++++根据凭证主键[" + $$$ppk_ags0 + "]未找到分录信息！");
        
        return cList;
    }
    
    public List<VoucherDetailVO> getDetailList(String $$$ppk_ags0) throws Exception
    {
        return getDetailList($$$ppk_ags0, Boolean.TRUE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 凭证 (gl_voucher)凭证主体权限 <br>
     * @see <br>
     * @param $$$ppk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @List<CustbankVO> <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getCustbankList <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:28:42 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public VoucherVO getVoucherByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        VoucherVO superVO = (VoucherVO) getSuperVOById($$$pk_ags0, VoucherVO.class);
        // VoucherVO superVO = (VoucherVO) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByPK(VoucherVO.class,
        // $$$pk_ags0);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的凭证信息！");
        
        return superVO;
        
    }
    
    public VoucherVO getVoucherByPk(String $$$pk_ags0) throws Exception
    {
        return getVoucherByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 供应商基本信息 (bd_supplier) <br>
     * @see <br>
     * @param $$$ppk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @List<CustbankVO> <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getCustbankList <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:28:42 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public SupplierVO getSupplierByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        SupplierVO superVO = (SupplierVO) getSuperVOById($$$pk_ags0, SupplierVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的供应商基本信息！");
        
        return superVO;
        
    }
    
    public SupplierVO getSupplierByPk(String $$$pk_ags0) throws Exception
    {
        return getSupplierByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 客商银行账户、供应商银行账号、客商银行账户 (bd_custbank) <br>
     * accclass 账户分类 accclass int 账户分类 0=个人，1=客户，2=公司，3=供应商， <br>
     * @see <br>
     * @param $$$ppk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @List<CustbankVO> <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getCustbankList <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:28:42 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    @SuppressWarnings("unchecked")
    public List<CustbankVO> getCustbankList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        List<CustbankVO> cList = (List<CustbankVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(CustbankVO.class,
            "(  pk_bankaccbas/*银行账户主键 */   ='" + $$$ppk_ags0 + "')or( pk_bankaccsub/*银行账户子户主键 */ ='" + $$$ppk_ags0 + "')");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(cList) < 1, folder, "+++++++++根据主键[" + $$$ppk_ags0 + "]未找到银行账户子户！");
        
        return cList;
    }
    
    public List<CustbankVO> getCustbankList(String $$$ppk_ags0) throws Exception
    {
        return getCustbankList($$$ppk_ags0, Boolean.TRUE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：银行账户子户、客商银行账户子户、个人银行账户子户 (bd_bankaccsub )<br>
     * @see <br>
     * @param $$$pk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @BankAccbasVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBankAccSubByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:20:56 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public BankAccSubVO getBankAccSubByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        BankAccSubVO superVO = (BankAccSubVO) getSuperVOById($$$pk_ags0, BankAccSubVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的银行账户子户 (bd_bankaccsub ) 信息！");
        
        return superVO;
        
    }
    
    public BankAccSubVO getBankAccSubByPk(String $$$pk_ags0) throws Exception
    {
        return getBankAccSubByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    @SuppressWarnings("unchecked")
    public List<BankAccSubVO> getBankAccSubList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        List<BankAccSubVO> cList = (List<BankAccSubVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(BankAccSubVO.class,
            " pk_psndoc ='" + $$$ppk_ags0 + "'");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(cList) < 1, folder, "+++++++++根据主键[" + $$$ppk_ags0 + "]未找到银行账户子户！");
        return cList;
    }
    
    public List<BankAccSubVO> getBankAccSubList(String $$$ppk_ags0) throws Exception
    {
        return getBankAccSubList($$$ppk_ags0, Boolean.TRUE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 银行账户、个人银行账户信息 、客商银行账户信息 (bd_bankaccbas) <br>
     * accclass 账户分类 账户分类 0=个人，1=客户，2=公司，3=供应商， <br>
     * enablestate 启用状态 1=未启用，2=已启用，3=已停用 <br>
     * @see <br>
     * @param $$$pk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @BankAccbasVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBankAccbasByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:20:56 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public BankAccbasVO getBankAccbasByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        BankAccbasVO superVO = (BankAccbasVO) getSuperVOById($$$pk_ags0, BankAccbasVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的银行账户 (bd_bankaccbas)  信息！");
        
        return superVO;
        
    }
    
    public BankAccbasVO getBankAccbasByPk(String $$$pk_ags0) throws Exception
    {
        return getBankAccbasByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：交易类型 (bd_billtype) <br>
     * @see <br>
     * @param $$$pk_ags0
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @BilltypeVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBilltypeByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-23 <br>
     * @time 上午10:16:17 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public BilltypeVO getBilltypeByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        BilltypeVO superVO = (BilltypeVO) getSuperVOById($$$pk_ags0, BilltypeVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的交易类型 (bd_billtype) 信息！");
        return superVO;
    }
    
    public BilltypeVO getBilltypeByPk(String $$$pk_ags0) throws Exception
    {
        return getBilltypeByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 自定义档案列表 (bd_defdoclist) <br>
     * @see <br>
     * @param $$$pk_ags0
     * @return
     * @throws Exception <br>
     * @PsnjobVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBdPsnjobByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:18:38 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public DefdoclistVO getDefdocListByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        DefdoclistVO superVO = (DefdoclistVO) getSuperVOById($$$pk_ags0, DefdoclistVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的自定义档案列表信息！");
        return superVO;
    }
    
    public DefdoclistVO getDefdocListByPk(String $$$pk_ags0) throws Exception
    {
        return getDefdocListByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 123124(自定义档案) (bd_defdoc) <br>
     * @see <br>
     * @param $$$pk_ags0
     * @return
     * @throws Exception <br>
     * @PsnjobVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBdPsnjobByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:18:38 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public DefdocVO getDefdocByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        DefdocVO superVO = (DefdocVO) getSuperVOById($$$pk_ags0, DefdocVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的自定义档案信息！");
        return superVO;
    }
    
    public DefdocVO getDefdocByPk(String $$$pk_ags0) throws Exception
    {
        return getDefdocByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    @SuppressWarnings("unchecked")
    public List<DefdocVO> getDefdocList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        List<DefdocVO> voList =
            (List<DefdocVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(DefdocVO.class, " pk_DefdocList ='" + $$$ppk_ags0 + "'");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(voList) < 1, folder,
            "+++++++++根据自定义档案列表主键[" + $$$ppk_ags0 + "]未找到对应的自定义档案信息！");
        return voList;
    }
    
    public List<DefdocVO> getDefdocList(String $$$ppk_ags0) throws Exception
    {
        return getDefdocList($$$ppk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 人员工作信息 (hi_psnjob) <br>
     * @see <br>
     * @param $$$pk_ags0
     * @return
     * @throws Exception <br>
     * @PsnjobVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBdPsnjobByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:18:38 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public PsnJobVO getHiPsnjobByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        PsnJobVO superVO = (PsnJobVO) getSuperVOById($$$pk_ags0, PsnJobVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的人员工作信息 (hi_psnjob)！");
        return superVO;
    }
    
    public PsnJobVO getHiPsnjobByPk(String $$$pk_ags0) throws Exception
    {
        return getHiPsnjobByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    @SuppressWarnings("unchecked")
    public List<PsnJobVO> getHiPsnjobList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        List<PsnJobVO> cList =
            (List<PsnJobVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(PsnJobVO.class, " pk_psndoc ='" + $$$ppk_ags0 + "'");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(cList) < 1, folder,
            "+++++++++根据人员主键[" + $$$ppk_ags0 + "]未找到人员工作信息 (bd_psnjob)！");
        return cList;
    }
    
    public List<PsnJobVO> getHiPsnjobList(String $$$ppk_ags0) throws Exception
    {
        return getHiPsnjobList($$$ppk_ags0, Boolean.TRUE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明： 人员工作信息 (bd_psnjob) <br>
     * @see <br>
     * @param $$$pk_ags0
     * @return
     * @throws Exception <br>
     * @PsnjobVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getBdPsnjobByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:18:38 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public PsnjobVO getBdPsnjobByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        PsnjobVO superVO = (PsnjobVO) getSuperVOById($$$pk_ags0, PsnjobVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的人员工作信息 (bd_psnjob)！");
        return superVO;
    }
    
    public PsnjobVO getBdPsnjobByPk(String $$$pk_ags0) throws Exception
    {
        return getBdPsnjobByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    @SuppressWarnings("unchecked")
    public List<PsnjobVO> getPsnjobList(String $$$ppk_ags0, Boolean isCheck) throws Exception
    {
        List<PsnjobVO> cList =
            (List<PsnjobVO>) YonYouUtilbc.getBaseDAOQueryBSyC().retrieveByClause(PsnjobVO.class, " pk_psndoc ='" + $$$ppk_ags0 + "'");
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.getSize(cList) < 1, folder,
            "+++++++++根据人员主键[" + $$$ppk_ags0 + "]未找到人员工作信息 (bd_psnjob)！");
        return cList;
    }
    
    public List<PsnjobVO> getPsnjobList(String $$$ppk_ags0) throws Exception
    {
        return getPsnjobList($$$ppk_ags0, Boolean.TRUE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：根据主键查询 组织_集团 (org_group) <br>
     * @see <br>
     * @param pk_ags
     * @return
     * @throws Exception <br>
     * @UserVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getOrgVOByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:09:29 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public GroupVO getGroupByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        GroupVO superVO = (GroupVO) getSuperVOById($$$pk_ags0, GroupVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的组织_集团信息！");
        return superVO;
    }
    
    public GroupVO getGroupByPk(String $$$pk_ags0) throws Exception
    {
        return getGroupByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：根据主键查询 组织_部门 (org_dept) <br>
     * @see <br>
     * @param pk_ags
     * @return
     * @throws Exception <br>
     * @OrgVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getOrgByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:11:50 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public DeptVO getDeptByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        DeptVO superVO = (DeptVO) getSuperVOById($$$pk_ags0, DeptVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的 组织_部门信息！");
        return superVO;
    }
    
    public DeptVO getDeptByPk(String $$$pk_ags0) throws Exception
    {
        return getDeptByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：根据主键查询 组织 (org_orgs) <br>
     * @see <br>
     * @param pk_ags
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @UserVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getOrgVOByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:09:29 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public OrgVO getOrgByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        OrgVO superVO = (OrgVO) getSuperVOById($$$pk_ags0, OrgVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的组织信息！");
        return superVO;
    }
    
    public OrgVO getOrgByPk(String $$$pk_ags0) throws Exception
    {
        return getOrgByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：根据主键查询 人员基本信息 (bd_psndoc) <br>
     * @see <br>
     * @param pk_ags
     * @param isCheck
     * @return
     * @throws Exception <br>
     * @OrgVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getOrgByPk <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午7:11:50 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public PsndocVO getPsndocByPk(String $$$pk_ags0, Boolean isCheck) throws Exception
    {
        PsndocVO superVO = (PsndocVO) getSuperVOById($$$pk_ags0, PsndocVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder,
            "+++++++++根据主键[" + $$$pk_ags0 + "]未找到对应的 人员基本信息信息！");
        return superVO;
    }
    
    public PsndocVO getPsndocByPk(String $$$pk_ags0) throws Exception
    {
        return getPsndocByPk($$$pk_ags0, Boolean.FALSE);
    }
    
    /**
     * *********************************************************** <br>
     * *说明：根据用户主键查询 用户sm_user <br>
     * @see <br>
     * @param user_id
     * @return
     * @throws BusinessException <br>
     * @UserVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getUserById <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午6:43:28 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     */
    public UserVO getUserById(String user_id, Boolean isCheck) throws Exception
    {
        UserVO superVO = (UserVO) getSuperVOById(user_id, UserVO.class);
        JudgeAssertUtil.checkAssertDir(isCheck && PubEnvUtil.isNullObj(superVO), folder, "+++++++++根据主键[" + user_id + "]用户未找到");
        return superVO;
    }
    
    public UserVO getUserById(String user_id) throws Exception
    {
        return getUserById(user_id, Boolean.FALSE);
    }
    
    @SuppressWarnings("unchecked")
    public List<SuperVO> getSuperVoByWhere(Class<?> Zlass, String whereStr, String orderStr) throws Exception
    {
        final SuperVO superVO = (SuperVO) Zlass.newInstance();
        String sql = SqlHelper.getSelectSQL(superVO.getTableName(), superVO.getAttributeNames(), whereStr, orderStr);
        return (List<SuperVO>) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, new BeanListProcessor(superVO.getClass()));
    }
    
    /**
     * *********************************************************** <br>
     * *说明：说明： 基类方法查询对应的SuperVO <br>
     * @see <br>
     * @param id
     * @param superVO
     * @return
     * @throws BusinessException <br>
     * @SuperVO <br>
     * @methods pers.bc.utils.yonyou.YonDBQuery#getSuperVOById <br>
     * @author LiBencheng <br>
     * @date Created on 2025-5-22 <br>
     * @time 下午6:55:42 <br>
     * @version 1.0 <br>
     *************************************************************          <br>
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public SuperVO getSuperVOById(final String id, final Class Zlass) throws Exception
    {
        final SuperVO superVO = (SuperVO) Zlass.newInstance();
        
        // String sql = "select * from " + superVO.getTableName() + " where " + superVO.getPKFieldName() +
        // " = ? ";
        
        String sql = SqlHelper.getSelectSQLBySeat(superVO.getTableName(), null, new LinkedHashMap<String, Object>()
        {
            {
                put(superVO.getPKFieldName(), id);
            }
        });
        SQLParameter para = new SQLParameter()
        {
            {
                addParam(id);
            }
        };
        // SQLParameter para = new SQLParameter(); para.addParam(id);
        return (SuperVO) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, para, new BeanProcessor(superVO.getClass()));
    }
    
    public Map getSuperVOById(Class<?> Zlass, String id) throws Exception
    {
        final SuperVO superVO = (SuperVO) Zlass.newInstance();
        String sql = SqlHelper.getSelectSQL(superVO.getTableName(), superVO.getAttributeNames(),//
            superVO.getPKFieldName() + PubEnvUtil.EQUALS + PubEnvUtil.SINGLE_QUOTE + id + PubEnvUtil.SINGLE_QUOTE, null);
        return (Map) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, new MapProcessor());
    }
    
    @SuppressWarnings("unchecked")
    public List<Map> getSuperByWhere(Class<?> Zlass, String whereStr, String orderStr) throws Exception
    {
        final SuperVO superVO = (SuperVO) Zlass.newInstance();
        String sql = SqlHelper.getSelectSQL(superVO.getTableName(), superVO.getAttributeNames(), whereStr, orderStr);
        return (List<Map>) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(sql, new MapListProcessor());
    }
    
    public List<Map> getDataByWhere(String tableName, String whereStr) throws Exception
    {
        return getDataByWhere(tableName, whereStr, null);
    }
    
    @SuppressWarnings("unchecked")
    public List<Map> getDataByWhere(String tableName, String whereStr, String orderStr) throws Exception
    {
        return (List<Map>) YonYouUtilbc.getBaseDAOQueryBSyC().executeQuery(//
            SqlHelper.getSelectSQL(tableName, null, whereStr, orderStr), new MapListProcessor());
    }
    
    private YonNccDB()
    {
    }
    
    String folder = "DBSessionogs";
    private static ThreadLocal<YonNccDB> yonDBUtilThread = new ThreadLocal<YonNccDB>();
    public static YonNccDB bdUtil = new YonNccDB();
    
    public static YonNccDB newUtil()
    {
        YonNccDB df = yonDBUtilThread.get();
        // if (null == df)
        // {
        // synchronized (YonyouTransUtil.class)
        // {
        if (null == df)
        {
            df = new YonNccDB();
            yonDBUtilThread.set(df);
        }
        // }
        // }
        
        return df;
    }
    
}
